<?php
    function load_submenu($parent_id){
    Zend_loader::loadclass('Admin_Models_AdminMenuModel');
    $db = new Admin_Models_AdminMenuModel();
    $list_sub = $db->loadsubmenu($parent_id);
    return $list_sub;
    
    }
?>
<a href="/admin/setting/add-menu"><input class="btn btn-success" type="button" value="Thêm menu"  ></input></a>
<p></p>
<table style="text-align: center" class="table table-hover table-bordered">
    <tr>
        <th>Stt</th>
        <th>Name Menu</th>
        <th>Ordering</th>
        <th>Remove</th>
    </tr>
    <?php $i=1; if($this->mainmenu){ ?>
    <?php foreach($this->mainmenu as $mainmenu_item){ ?>
    <tr>
        <td style="text-align: center"><?php echo $i; ?></td>
        <td style="text-align: left"><?php echo $mainmenu_item['name']; ?></td>
        <td><?php echo $mainmenu_item['ordering']; ?></td>
        <td><a href="/admin/setting/list-menu/?del_menu=<?php echo $mainmenu_item['id'];?>"><i  onclick="return confirm('Are you sure?')" class="icon-trash"></i></a></td>
    </tr>
    <?php $list_sub = load_submenu($mainmenu_item['id']);?>
    <?php  if(isset($list_sub)){ ?>
    <?php foreach($list_sub as $submenu_item) {?>
     <tr>
        <td><?php echo ''; ?></td>
        <td style="text-align: left">--------------<?php echo $submenu_item['name']; ?></td>
        <td><?php echo $submenu_item['ordering']; ?></td>
        <td><a href="/admin/setting/list-menu/?del_menu=<?php echo $submenu_item['id'];?>"><i  onclick="return confirm('Are you sure?')" class="icon-trash"></i></a></td>
    </tr>
    <?php }?>
     <?php }?>
     <?php $i++; }?>
    <?php }?>
</table>